﻿
using MauiApp1.Custom;
using MauiApp1.View;

namespace MauiApp1;

public partial class MainPage : CustomMenu
{
    private readonly MainViewModel _mainViewModel;


    public MainPage()
    {
        InitializeComponent();
        _mainViewModel = ServiceProvider.GetService<MainViewModel>();

        this.BindingContext = _mainViewModel;

    }

    private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
    {
        var grid = (Grid)sender;

        var viewType = (Type)grid.BindingContext;
       

        _mainViewModel.Rote = (Microsoft.Maui.Controls.View)Tools.CreateInstance(viewType.Namespace, viewType.Name, null);
        //switch (grid.BindingContext)
        //{
        //    case "NewContent1":
        //        _mainViewModel.Rote = new NewContent1();
        //        break;
        //    case "NewContent2":
        //        _mainViewModel.Rote = new NewContent2();
        //        break;
        //    case "NewContent3":
        //        _mainViewModel.Rote = new NewContent3();
        //        break;
        //    case "NewContent4":
        //        _mainViewModel.Rote = new NewContent4();
        //        break;

        //    default:
        //        break;
        //}
    }
}

